package com.sise.controller;

import com.sise.bean.CodeMsg;
import com.sise.entity.Admin;
import com.sise.service.IAdminService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author zj
 */
@RestController
@RequestMapping("/sise/admin")
public class AdminController {

    @Resource
    private IAdminService iAdminService;

    @PostMapping("/login")
    public ModelAndView login(Admin admin) {
        return iAdminService.login(admin);
    }

    @PostMapping("/weblogin")
    public CodeMsg weblogin(Admin admin, HttpServletRequest request) {
        return iAdminService.weblogin(admin);
    }

    @PostMapping("/changePassword")
    public CodeMsg changePassword(Admin admin, String password) {
        return iAdminService.changePassword(admin, password);
    }

    @PostMapping("/permissionVerification")
    public CodeMsg permissionVerification(Admin admin) {
        return iAdminService.permissionVerification(admin);
    }

    @PostMapping("/getAllAdmin")
    public CodeMsg getAllAdmin(Admin admin) {
        return iAdminService.getAllAdmin(admin);
    }

    @PostMapping("/deleteAdminById")
    public CodeMsg deleteAdminById(Integer userId, Integer id) {
        return iAdminService.deleteAdminById(userId, id);
    }

    @PostMapping("/resetAdminById")
    public CodeMsg resetAdminById(Integer userId, Integer id) {
        return iAdminService.resetAdminById(userId, id);
    }

    @PostMapping("/addAdmin")
    public CodeMsg addAdmin(Integer userId, String adminAccount) {
        return iAdminService.addAdmin(userId, adminAccount);
    }

    @PostMapping("/oneClickReset")
    public CodeMsg oneClickReset(Integer[] operationIdList, Integer userId) {
        return iAdminService.oneClickReset(operationIdList, userId);
    }

    @PostMapping("/oneClickDelete")
    public CodeMsg oneClickDelete(Integer[] operationIdList, Integer userId) {
        return iAdminService.oneClickDelete(operationIdList, userId);
    }
}
